Skip to main content
This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal

HCL Notes/Domino 8.5 Forum (includes Notes Traveler)

HCL Notes/Domino 8.5 Forum (includes Notes Traveler)

Previous Next

Update: Now it can be in UI but this isn't working...

When I said that the export functions I was trying to do were all UI based and I couldn't find a way to do it in the back end, my supervisor said, "So what?" We are going to have a dedicated workstation that can spin for as long as it needs to on these exports. So I have this script... any help??

Before you yell at me for using Evaluate, let me tell you why. I'll be using this tool on 800 databases and they all have different field names. I have to be able to run it without customizing the script for each form. Any ideas or code samples greatly appreciated! Thanks folks!

Edit: The result here is that I look in the file folder and nothing has been exported. Am I building the formula string (strFormula) wrong?

Trish


Sub Click(Source As Button)
On Error Goto ErrHandler

'Initialize variables
Dim session As NotesSession
Dim uiws As New NotesUIWorkspace
Dim uidb_this As NotesUIDatabase
Dim db_this As NotesDatabase
Dim db_target As NotesDatabase
Dim uidoc_this As NotesUIDocument
Dim doc_this As NotesDocument
Dim uidoc_target As NotesUIDocument
Dim doc_target As NotesDocument
Dim doc_target_next As NotesDocument
Dim view_target As NotesView
Dim ViewEntryCount As Integer
Dim TotalCount As Integer
Dim SuccessCount As Integer
Dim FormItem As NotesItem
Dim TextObj As Variant
Dim ExportNum As Integer
Dim strFormula As String
Dim bExport As Boolean
Dim MyFileName As String
Dim ndtBegin As NotesDateTime
Dim ndtEnd As NotesDateTime

'Get session, current database, target database & target view
Set session = New NotesSession
Set ndtBegin = session.CreateDateTime(Now)
Set uidb_this = uiws.CurrentDatabase
Set db_this = uidb_this.Database
Set uidoc_this = uiws.CurrentDocument
Set doc_this = uidoc_this.Document
Set db_target = session.GetDatabase( uidoc_this.FieldGetText("ServerNam"), uidoc_this.FieldGetText("DBPath"), False)
If db_target Is Nothing Then
Messagebox "Cannot find the target database. Please check the field values and try again."
Exit Sub
End If
Set view_target = db_target.GetView(uidoc_this.FieldGetText("ViewNam"))
If view_target Is Nothing Then
Messagebox "Cannot find the target view. Please check the field values and try again."
Exit Sub
End If
ViewEntryCount = view_target.EntryCount
If ViewEntryCount = 0 Then
Messagebox "Found 0 documents in the target view."
Exit Sub
End If

'Loop through documents and perform an export for each one with a form marked for export
TotalCount = 0
SuccessCount = 0
bExport = False
If uidoc_this.FieldGetText("ExportNum") = "" Then
Messagebox "Specify how many documents to export. Use 0 to get all documents in the target view."
Exit Sub
End If
ExportNum = Cint( uidoc_this.FieldGetText("ExportNum"))
If ExportNum = 0 Then
ExportNum = ViewEntryCount
End If
Set FormItem = doc_this.GetFirstItem("FormNam") 'This is the form(s) we are exporting
Do Until SuccessCount = ExportNum
If TotalCount = ViewEntryCount Then
Exit Do
End If
TotalCount = TotalCount + 1
Print "Total Count: " + Cstr(TotalCount) + " Exported: " + Cstr(SuccessCount)
'Get the target doc
Set doc_target = view_target.GetNthDocument(TotalCount)
'Determine if the target doc's form is one that we are exporting
bExport = FormItem.Contains(doc_target.Form(0))
If bExport Then
'We are exporting, so open the target doc in the UI
Set uidoc_target = uiws.EditDocument( False, doc_target, True , , True , True )
MyFileName = Cstr(SuccessCount + 1) + ".txt"
strFormula = "@Command([FileExport]; " & Chr(34) & "ASCII" & Chr(34) & "; "& Chr(34) & doc_this.FilePath_Dbl(0) & Chr(92) & Chr(92) & MyFileName & Chr(34) & ")"
' Messagebox strFormula
Evaluate strFormula <---- the formula ends up being something like this: @Command([FileExport]; "ASCII"; "C:\\Users\\me\\Desktop\\Test Data\\1.txt")

Call uidoc_target.Close(True)
SuccessCount = SuccessCount + 1
End If
Set uidoc_target = Nothing
Set doc_target_next = view_target.GetNthDocument(TotalCount)
Set doc_target = doc_target_next
Set doc_target_next = Nothing
bExport = False
MyFileName = ""
Loop
Set ndtEnd = session.CreateDateTime(Now)
doc_this.BeginExport = Cstr(ndtBegin.DateOnly) + " " + Cstr(ndtBegin.TimeOnly)
doc_this.EndExport = Cstr(ndtEnd.DateOnly) + " " + Cstr(ndtEnd.TimeOnly)
doc_this.RunTime = Cstr(ndtEnd.TimeDifference(ndtBegin))
doc_this.Result_Text = Cstr(SuccessCount)
doc_this.ExportStatus = "Run Successfully (unverified)"
uidoc_this.EditMode = True
Call doc_this.Save(True, False, True)
Call uidoc_this.Reload()
Exit Sub

ErrHandler:
'Log an error here!
Messagebox("ERROR " & Cstr(Err) & ": " & Error$ & " on line " & Cstr(Erl))
Exit Sub

End Sub


Feedback response number WEBB8UUPBY created by ~Umberto Quetwegenoopsi on 06/01/2012

How to do backend lotusscript expor... (~Umberto Quetwe... 31.May.12)
. . Intractable problem I think... (~Tip Opjipymanl... 1.Jun.12)
. . . . Will you look at my code? (~Umberto Quetwe... 1.Jun.12)
. . Update: Now it can be in UI but thi... (~Umberto Quetwe... 1.Jun.12)
. . notesstream (~Hank Quetrepul... 31.May.12)
. . . . NotesStream (~Umberto Quetwe... 1.Jun.12)
. . . . . . Exporting to plain text (~Denise Chutoog... 12.Jun.12)
. . . . . . . . Exporting to text files (~Umberto Quetwe... 12.Jun.12)




Printer-friendly

Search this forum

Member Tools


RSS Feeds

 RSS feedsRSS
All forum posts RSS
All main topics RSS